﻿using LianXi1013.Entity.User;
using LianXi1013.Service.User;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace LianXi1013.WebAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IUserInforService userInforService;

        public UserController(IUserInforService userInforService)
        {
            this.userInforService = userInforService;
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        [HttpGet("LoginUser")]
        public IActionResult LoginUser(string name,string password)
        {
            return Ok(userInforService.LoginUser(name, password));
        }

        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        [HttpPost("LoginUser")]
        public IActionResult AddUser(UserInfor u)
        {
            return Ok(userInforService.AddUser(u));
        }
    }
}
